package com.yuantu.judiciary.model.domain;

import com.yuantu.judiciary.model.BaseDO;
import com.yuantu.judiciary.model.enums.AuthResultType;
import com.yuantu.judiciary.model.enums.EndpointType;
import com.yuantu.judiciary.model.enums.SearchType;
import lombok.Data;
import org.hibernate.annotations.Comment;
import org.hibernate.annotations.DynamicUpdate;

import javax.persistence.*;
import java.sql.Timestamp;

/**
 * 查询记录
 *
 * @author syw
 * @since 2023-07-04
 **/
@Data
@Entity
@DynamicUpdate
@Table(name = "query_record")
public class QueryRecordDO extends BaseDO {

    /**
     * 查询内容
     */
    @Column(columnDefinition = "text")
    @Comment("查询内容")
    private String content;

    /**
     * 查询类型
     */
    @Enumerated(EnumType.STRING)
    @Column(length = 100, nullable = false)
    @Comment("查询类型")
    private SearchType type;

    /**
     * 授权结果
     */
    @Enumerated(EnumType.STRING)
    @Column(length = 100, nullable = false)
    @Comment("授权结果")
    private AuthResultType authorizedResult;

    /**
     * 过期时间，不填写默认不过期
     */
    @Column(columnDefinition = "datetime")
    @Comment("过期时间")
    private Timestamp expiresTime;

    /**
     * 授权时间
     */
    @Comment("授权时间")
    private Timestamp authorizedTime;

    /**
     * 查询实体id
     */
    @Comment("查询实体id")
    private Long entityId;

    /**
     * 是否关注
     */
    @Column(name = "is_followed")
    @Comment("是否关注")
    private Boolean followed = Boolean.FALSE;

    /**
     * 再次发起时间
     */
    @Comment("再次发起时间")
    private Timestamp againTime;

    /**
     * 获取最新数据时间
     */
    @Comment("获取最新数据时间")
    private Timestamp latestDataTime;

    /**
     * 是否是示例
     */
    @Column(name = "is_example")
    @Comment("是否是示例")
    private Boolean example = Boolean.FALSE;

    /**
     * 来源：APP、平台端、小程序、ALIPAY_APPLET
     */
    @Enumerated(EnumType.STRING)
    @Column(length = 20)
    @Comment("来源：APP、平台端、小程序、支付宝小程序")
    private EndpointType origin;

    /**
     * 订单编号（仅支付宝小程序付款时有值）
     */
    @Comment("订单编号（仅支付宝小程序付款时有值）")
    private String tradeNo;

    /**
     * 是否是查自己
     */
    @Column(name = "is_self")
    @Comment("是否是查自己")
    private Boolean self = Boolean.FALSE;

    /**
     * 是否显示记录
     */
    @Column(name = "is_show")
    @Comment("是否显示记录")
    private Boolean show = Boolean.TRUE;


    @Comment("是否需要查询授权书")
    private Boolean isFile = Boolean.FALSE;

    private String codeInfo;

    private Long shopId;
}
